package com.zzh.zzhaiagent.rag.local;

import jakarta.annotation.Resource;
import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.vectorstore.SimpleVectorStore;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author: zzh
 * @date: 2025/05/07 14:25:45
 * @version: 1.0
 */
//配置SimpleVectorStore基于内存实现的向量存储
@Configuration
public class LoveAppVectorStoreConfig {

    @Resource
    private LoveAppDocumentLoader loveAppDocumentLoader;

    /**
     * 配置SimpleVectorStore基于内存实现的向量存储
     * @param dashscopeEmbeddingModel 注入EmbeddingModel dashscope的EmbeddingModel
     * @return
     */
    @Bean
    public VectorStore loveAppVectorStore(EmbeddingModel dashscopeEmbeddingModel) {
        SimpleVectorStore simpleVectorStore = SimpleVectorStore.builder(dashscopeEmbeddingModel).build();

////        //加载用户文档(mysql)
//        List<Document> documentList1 = loveAppDocumentLoader.loadUserDocuments();
//        simpleVectorStore.add(documentList1);
////
////        //加载文档
//        List<Document> documentList = loveAppDocumentLoader.loadMarkdownDocuments();
//        simpleVectorStore.add(documentList);

//        System.out.println("document文档列表：" + documentList);
        return simpleVectorStore;
    }

}
